✨ BCA JUL24 Batch ✨

Join Our WhatsApp Group

Anukasif Pic

2.4 - Input Output - MCQs

Interactive MCQs Quiz

Test your knowledge with these questions

1. Which of the following functions is used to display output on the screen in C?

2. What is the purpose of the scanf() function in C?

3. What is the correct format specifier to scan an integer using scanf()?

4. Which of the following format specifiers is used to scan or print a floating-point number?

5. What does the format specifier %c represent in C's scanf() and printf() functions?

6. Which of the following format specifiers is used to scan or print a string in C?

7. In C, the format specifier %lf is used to scan or print which type of data?

8. Which of the following is a formatted input/output function in C?

9. What header file is required for using scanf() and printf() functions in C?

10. What is the correct output for the following C code?

#include <stdio.h>
                int main() {
                    int num;
                    printf("Enter an integer: ");
                    scanf("%d", &num);
                    printf("The integer is %d", num);
                    return 0;
                }

11. What does the getchar() function do in C?

12. How does the putchar() function work?

13. What is the purpose of the gets() function?

14. What does the puts() function do?

15. Which function would you use to read multiple characters in a loop?

16. Which function is typically used to display a single character on the screen?

17. What happens if you use gets() without a buffer large enough to hold the input?

18. Which function should be used if you want to display a string with a newline at the end?

19. How can you read more than one character using getchar()?

20. Which of the following is true about gets() and fgets()?

21. What is the primary purpose of the fprintf() function in C?

22. How does the fscanf() function work in C?

23. Which function is used to read formatted data from a string buffer and store it in variables?

24. What does the sprintf() function do?

25. What is the key difference between fprintf() and printf()?

26. Which function would you use to read formatted data from a string buffer?

27. When using sprintf(), what should be considered regarding the buffer size?

28. What is the role of the format parameter in fscanf() and fprintf() functions?

29. Which function would you use to print formatted data to the console?

30. If you need to read formatted data from a file using a file pointer, which function would you use?

31. What is the main purpose of the sscanf() function?

32. How do you handle errors when using the fprintf() function?

33. What should be done if fscanf() does not read data as expected?

34. Which function should you use if you need to format values into a character array without printing them?

35. How do sprintf() and sscanf() differ from printf() and scanf()?

36. In which scenario would you use sprintf() over printf()?